function sys = pid_sys(domain, kp, fi, fd)

% init
if strcmp(domain{1}, "s")
    
elseif strcmp(domain{1}, "z")
    Ts = domain{2};
end


% design
wi = 2*pi*fi;
wd = 2*pi*fd;


s = tf("s");

if wd ~= 0
    sys_s = kp * (1 + wi/s) * (1 + s/wd);
else
    sys_s = kp * (1 + wi/s);
end


% output
if strcmp(domain{1}, "s")
    sys = sys_s;
elseif strcmp(domain{1}, "z")
    sys_z = c2d(sys_s, Ts, 'tustin');
    sys = sys_z;
end

end